package ua.kpi.flats.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import ua.kpi.flats.util.JsonDateSerializer;

@Entity
@Table(name = "CONTRACT")
@JsonAutoDetect
public class Contract implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "CONTACTID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	
	@Column(name = "CREATE_DATE")
	private Date createDate;
	
	@OneToOne
	@JoinColumn(name = "BUYID")
	private BuyApplication buyApplication;
	
	@OneToOne
	@JoinColumn(name = "SALEID")
	private SaleApplication saleApplication;
	
	@Column(name = "MONEY")
	private BigDecimal money;
	
	@Column(name = "CONTRACT_NUMBER")
	private String number;
	
	public Contract() {
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	@JsonSerialize(using=JsonDateSerializer.class)
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public BuyApplication getBuyApplication() {
		return buyApplication;
	}

	public void setBuyApplication(BuyApplication buyApplication) {
		this.buyApplication = buyApplication;
	}

	public SaleApplication getSaleApplication() {
		return saleApplication;
	}

	public void setSaleApplication(SaleApplication saleApplication) {
		this.saleApplication = saleApplication;
	}

	public BigDecimal getMoney() {
		return money;
	}

	public void setMoney(BigDecimal money) {
		this.money = money;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}
}
